using TMPro;
using UnityEngine;
using Voodoo.Pattern;

public class Money : SingletonMB<Money>
{
	[SerializeField]
	private TextMeshProUGUI text;

	private int _lastMoney = -1;

	private void Start()
	{
		Debug.Log("start被调用");
		UpdateValue();
	}

	public void UpdateValue()
	{
		int num = (int)NintendoPlayerPrefs.GetFloat("Money", 0f) + SingletonMB<GameManager>.Instance.DeltaMoney;
		if (num != _lastMoney)
		{
			text.text = num + "$";
		}
		_lastMoney = num;
	}

	private void Update()
	{
		UpdateValue();
	}
	public void GetMoney(int money)
	{
		AdManager.Instance.ShowVideo(() =>
		{
			NintendoPlayerPrefs.SetFloat("Money", NintendoPlayerPrefs.GetFloat("Money", 0f) + money);
			UpdateValue();
			Shop.Instance.CheckButtons();
		});
	}
}
